package org.db2.project.airline.dao.impl;

import org.db2.project.airline.utils.HibernateHelper;
import org.hibernate.Session;
import org.hibernate.SessionFactory;

/**
 *
 */
public class HibernateBaseDAO {

    /**
     * <p>Represents the instance of hibernate's {@link SessionFactory} class.</p>
     */
    private final SessionFactory sessionFactory;

    /**
     * <p>Creates new instance of {@link HibernateBaseDAO} class.</p>
     */
    protected HibernateBaseDAO() {

        sessionFactory = HibernateHelper.getSessionFactory();
    }

    /**
     * <p>Retrieves the session factory.</p>
     *
     * @return the session factory instance
     */
    public SessionFactory getSessionFactory() {

        return sessionFactory;
    }

    /**
     * <p>Retrieves the current hibernate session.</p>
     *
     * @return the current hibernate session
     */
    public Session getSession() {

        return sessionFactory.getCurrentSession();
    }
}
